﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BeerScanOTron_Barcode
{
    public static class ExtensionMethods
    {
        public static char GetKeyValue(this KeyEventArgs e)
        {
            // If the key is numeric we have to help it into it's proper char representation.
            if (e.KeyValue >= ((int)Keys.D0) && e.KeyValue <= ((int)Keys.D9))
            {
                return (char)((int)e.KeyValue - ((int)Keys.D0)).ToString()[0];
            }
            else
            {
                return Convert.ToChar(e.KeyCode);
            }
        }
    }
}
